'''
此文件为调用mysq连接文件及sql_created_info进行数据库的执行操作
'''
from TongYong.Sql_connect import SQL_connect
import Config.sql_created_info
from TongYong.Decode_ini_yaml import Decode_yaml
import redis
from TongYong.Log_Info import Log

class Db_created:
    print("调用开始")
    '''
    构造函数，获取到要连接的数据库的相关信息，如
    '''
    def __init__(self,sql_info_tag = Config.sql_created_info.sql_treated_info):
        # 调用sql_treated_info中的节点信息；
        self.sql_info_tag = sql_info_tag
        # 调用yaml解析函数获取到sql数据库节点
        self.sql_config_path = Decode_yaml.get_ymal_config_node(self.sql_info_tag)

    def mysql_created(self,sql_node = "mysql",data_type = 1 ):
        print("来到这")
        mysql_info =self.sql_config_path.get(sql_node)
        mysql_created_info = SQL_connect(mysql_info,data_type)

        return mysql_created_info

    def redis_created(self,sql_node = "redis"):
        print("或者是redis")
        redis_info = self.sql_config_path.get(sql_node)
        Log.debug("redis的配置：{}", redis_info)
        redis_creatde_info = redis.Redis(**redis_info,decode_responses = True)